﻿using System.Data.OleDb;
using System.Data.SqlClient;

namespace ExcelDataRetriever
{
    class Program
    {
        static void Main(string[] args)
        {
            OleDbConnection con = new OleDbConnection(@"Provider = Microsoft.ACE.OLEDB.12.0;Data Source = ..\..\ExcelFiles\Sales-Kaspichan.xlsx;Extended Properties=""Excel 8.0;HDR=Yes""");
            con.Open();
            using (con)
            {
                OleDbCommand com = con.CreateCommand();
                com.CommandText = "Select * from [Sheet1$]";
                var reader = com.ExecuteReader();
                using (reader)
                {
                    while (reader.Read())
                    {
                        string result = (string)reader['A'];
                        System.Console.WriteLine(result);
                    }
                }

            }
        }
    }
}
